<template>
    <div class="newsinfo-container">
        <h4>{{newsinfo.title}}</h4>
        <div class="newsinfo-timebar">
            <span>发表时间:{{newsinfo.add_time}}</span>
            <span>点击:{{newsinfo.click}}次</span>
        </div>
        <hr>
        <div v-html="newsinfo.content"></div>
        <comment-box :id="this.id"></comment-box>
    </div>
</template>

<script>
import {Toast} from 'mint-ui'
import comment from '../comments/comment.vue'
export default {
    data() {
        return {
            id: this.$route.params.id,
            newsinfo:[]
        }
    },
    created(){
        this.getnewsinfo()
    },
    methods: {
        getnewsinfo() {
            this.$http.get('api/getnew/'+ this.id).then(function(result){
                if(result.body.status === 0){
                this.newsinfo = result.body.message[0]
                }else {
                    Toast({
                        message: '数据错误'
                    })
                }
               
            })
        }
    },
    components: {
        "comment-box":comment
    }
}
</script>

<style lang="less" scoped>
    .newsinfo-container{
        padding: 0 5px;
        h4{
            text-align: center;
            color: red;
             margin:10px,0;
        }
        .newsinfo-timebar{
            display: flex;
            justify-content: space-between;
            font-size: 12px;
            color: blue
        }
    }
</style>
